home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
tools
/
grid.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
2KB
|
97 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* grid -
* Draw a 10 by 10 grid. This is useful for aligning
* a camera to the display.
*
* Paul Haeberli - 1986
*/
#include <gl/gl.h>
#include <gl/device.h>
int drawit();
main()
{
short val;
makewindow();
drawit();
while(1)
switch(qread(&val)) {
case REDRAW:
drawit();
break;
case LEFTMOUSE:
case RIGHTMOUSE:
case KEYBD:
case ESCKEY:
exit(0);
break;
}
}
drawit()
{
reshapeviewport();
ortho2(0.0,1.0,0.0,1.0);
pushmatrix();
color(0);
clear();
color(7);
drawgrid(10,10);
popmatrix();
}
/*
* Make a grid.
*
*/
drawgrid(xdivs,ydivs)
int xdivs, ydivs;
{
int i;
float x, y;
for(i=1; i<xdivs; i++) {
x = (float)i/xdivs;
move2(x,0.0);
draw2(x,1.0);
}
for(i=1; i<ydivs; i++) {
y = (float)i/ydivs;
move2(0.0,y);
draw2(1.0,y);
}
}
makewindow()
{
long xmaxscreen, ymaxscreen;
xmaxscreen = getgdesc(GD_XPMAX);
ymaxscreen = getgdesc(GD_YPMAX);
noborder();
prefposition(0, xmaxscreen, 0, ymaxscreen);
winopen ("grid");
qdevice(KEYBD);
qdevice(ESCKEY);
qdevice(RIGHTMOUSE);
qdevice(LEFTMOUSE);
}